<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>四六级在线报名系统-报名页面</title>
  <script src="js/jquery-3.3.1.min.js"></script>
	<link rel="stylesheet" href="layui/css/layui.css" media="all"></link>
	<script src="layui/layui.js"></script>
	<script src="layer/layer.js"></script>
	<link rel="stylesheet" href="layer/mobile/need/layer.css" />
	<link rel="stylesheet"  href="layer/theme/default/layer.css"/>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header" style="background-color: #F0F0F0;">
    <div class="layui-logo">
    	<img src="img/161230188.jpg"  height="90%"/>
    </div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
 </ul>
    <ul class="layui-nav layui-layout-right">
    	
    	     <li class="layui-nav-item"> <a href="cethome.html"><font size="5" color="#000">首页</font></a></li>
<li class="layui-nav-item"><a href="about.html" target="_self"><font size="5" color="#000">考试简介</font></a> </li>
<li class="layui-nav-item"><a href="time.html" target="_self"><font size="5" color="#000">考试动态</font></a> </li>
<li class="layui-nav-item"><a href="problems.html" target="_self"><font size="5" color="#000">常见问题</font></a> </li>
<li class="layui-nav-item"><a href="tips.html" target="_self"><font size="5" color="#000">温馨提示</font></a> </li>
   
    	
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img   id="uimg" class="layui-nav-img">
            <font size="5" color="#4E5465"><span id="name"></span></font>
        </a>
        <dl class="layui-nav-child">
          <dd><a  onclick="getUserAndRoles()">基本资料</a></dd>
          <dd><a  onclick="upfile()">修改头像</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a  onclick="logout()"><font size="4" color="#000000">退出登录</font></a></li>
    </ul>
  </div>
  <!--添加或编辑用户-->
		<div id="setUser" class="layer_self_wrap" style="width:500px;display:none;">
			<form id="userForm" class="layui-form layui-form-pane" method="post" action="" style="margin-top: 20px;">

				<input id="Id" type="hidden" name="id" />
				<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-inline">
						<input id="OrdinaryUserName" name="OrdinaryUserName" lay-verify="required" autocomplete="off" class="layui-input" type="text" />
					</div>
				</div>
			<div class="layui-form-item">
					<label class="layui-form-label">身份证</label>
					<div class="layui-input-inline">
						<input id="IdNumber" name="IdNumber" lay-verify="required" autocomplete="off" class="layui-input" type="text" />
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input id="OrdinaryUserPassword" name="OrdinaryUserPassword" lay-verify="required" autocomplete="off" class="layui-input" type="hidden"    />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邮箱</label>
					<div class="layui-input-inline">
						<input id="OrdinaryUserEmail" name="OrdinaryUserEmail" lay-verify="required | email" autocomplete="off" class="layui-input" type="text" />
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-inline" id="Img">
				   	<input id="OrdinaryUserImg" name="OrdinaryUserImg" lay-verify="required | email" autocomplete="off" class="layui-input" type="hidden" />
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input id="OrdinaryUserStatus" name="OrdinaryUserStatus" lay-verify="required | school" autocomplete="off" class="layui-input" type="hidden" />
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block" style="margin-left: 10px;">
						<button class="layui-btn" lay-submit=""   lay-filter="userSubmit">提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
			</div>
		</div>
		<form id="imgfile" class="layui-form layui-form-pane" enctype="multipart/form-data"   method="post" action="">
		<div id="upfile" style="display: none; width: 200px;height: 200px;">
			<div class="layui-upload">
				<div align="center">
				<img  id="uimgs" alt="点击修改头像" color="red" onclick="F_Open_dialog()" width="150px" height="150px"/>
				</div>
				<input name="email" type="hidden" id="email" />
				<input type="file" name="files" multiple="multiple" id="files" onchange="preImg(this.id,'uimgs');"  style="display: none;" />
				<div align="center">
         <button class="layui-btn" lay-submit="" lay-filter="imgfile">提交</button>
				 <button type="reset" class="layui-btn layui-btn-primary">重置</button>
				 </div>
 
  </form>
</div>   
		</div>
<script src="js/header.js">
</script>
<script>
	data=localStorage.getItem("cuser");
	data=JSON.parse(data);
	console.log(data);
  document.getElementById("email").value = data.ordinaryUserEmail;
		function getFileUrl(sourceId) { 
		var url; 
		if (navigator.userAgent.indexOf("MSIE")>=1) { // IE 
			url = document.getElementById(sourceId).value; 
			} else if(navigator.userAgent.indexOf("Firefox")>0) { // Firefox 
			url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0)); 
			} else if(navigator.userAgent.indexOf("Chrome")>0) { // Chrome 
			url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0)); 
			} 
		return url; 
		} 
	
/** 
* 将本地图片 显示到浏览器上 
*/ 
		function preImg(sourceId, targetId) { 
		var url = getFileUrl(sourceId); 
		var imgPre = document.getElementById(targetId); 
		imgPre.src = url; 
		} 

        function F_Open_dialog() 
       { 
            document.getElementById("files").click(); 
       } 
	
	
	
	 layui.use('table', function() {
		var table = layui.table,
			form = layui.form;
		form.on('submit(imgfile)', function(data) {
			upimg();
			return false;
		});
	});
function upimg()
{
var formData = new FormData(document.getElementById("imgfile"));//表单id
$.ajax({
   url: rooturl+'upfile' ,
   type: 'POST',
   data: formData,
   async: false,
   cache: false,
   contentType: false,
   processData: false,
   success: function (data) {
   	layer.alert("修改头像成功，请重新登录！",function(){
   		localStorage.removeItem('cuser');
    	window.location.href="login.html";
    });
   }
});	
}


</script>
<iframe name="iframe" id="iframe" src="main.html" width="100%" height=800px></iframe>
</body>
</html>